﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
using DevExpress.XtraEditors;
using System.IO;
using COMOSOFT.Class;
using System.Deployment.Application;
using COMOSOFT.Production.Report;
using DevExpress.XtraReports.UI;
using DevExpress.LookAndFeel;

namespace COMOSOFT
{
    public partial class FrmEX : Form
    {
        ClassShare cls = new ClassShare("FrmEX");
        //string path;        
        public FrmEX()
        {
            InitializeComponent();
        }

        private void bnt_Send_Click(object sender, EventArgs e)
        {
            try
            {
                //WebClient webcl = new System.Net.WebClient();
                //string To = txt_To.Text;
                //string mess = txt_Mess.Text;
                //string Address = "http://api.clickatell.com/http/sendmsg?user=comosoft&password=tO4RXHko&api_id=3522227&to='" + To + "'&text='" + mess + "'";
                //webcl.OpenRead(Address);
                //MessageBox.Show("send successfully");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        #region [AutoUpdate]
        private void InstallUpdateSyncWithInfo()
        {
            UpdateCheckInfo info = null;

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;

                try
                {
                    info = ad.CheckForDetailedUpdate();

                }
                catch (DeploymentDownloadException dde)
                {
                    MessageBox.Show("The new version of the application cannot be downloaded at this time. \n\nPlease check your network connection, or try again later. Error: " + dde.Message);
                    return;
                }
                catch (InvalidDeploymentException ide)
                {
                    MessageBox.Show("Cannot check for a new version of the application. The ClickOnce deployment is corrupt. Please redeploy the application and try again. Error: " + ide.Message);
                    return;
                }
                catch (InvalidOperationException ioe)
                {
                    MessageBox.Show("This application cannot be updated. It is likely not a ClickOnce application. Error: " + ioe.Message);
                    return;
                }

                if (info.UpdateAvailable)
                {
                    Boolean doUpdate = true;

                    if (!info.IsUpdateRequired)
                    {
                        DialogResult dr = MessageBox.Show("An update is available. Would you like to update the application now?", "Update Available", MessageBoxButtons.OKCancel);
                        if (!(DialogResult.OK == dr))
                        {
                            doUpdate = false;
                        }
                    }
                    else
                    {
                        // Display a message that the app MUST reboot. Display the minimum required version.
                        MessageBox.Show("This application has detected a mandatory update from your current " +
                            "version to version " + info.MinimumRequiredVersion.ToString() +
                            ". The application will now install the update and restart.",
                            "Update Available", MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
                    }

                    if (doUpdate)
                    {
                        try
                        {
                            ad.Update();
                            MessageBox.Show("The application has been upgraded, and will now restart.");
                            Application.Restart();
                        }
                        catch (DeploymentDownloadException dde)
                        {
                            MessageBox.Show("Cannot install the latest version of the application. \n\nPlease check your network connection, or try again later. Error: " + dde);
                            return;
                        }
                    }
                }
            }
        }
        #endregion

        private void FrmEX_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dataSet_Production.StyleList' table. You can move, or remove it, as needed.
           
            // TODO: This line of code loads data into the 'dataSet_Production.OrderStyleLists' table. You can move, or remove it, as needed.
           
            // TODO: This line of code loads data into the 'dataSet_Production.OrderStyleLists' table. You can move, or remove it, as needed.
           
            // TODO: This line of code loads data into the 'dataSet_Production.Item' table. You can move, or remove it, as needed.
            this.itemTableAdapter.Fill(this.dataSet_Production.Item);
            // TODO: This line of code loads data into the 'dataSetOrderManagement.sp_OrderGetMA' table. You can move, or remove it, as needed.
            this.sp_OrderGetMATableAdapter.Fill(this.dataSetOrderManagement.sp_OrderGetMA);



        }
    }
}
